/* 评价列表 */
function pingjia_list0() {
    let mockData = Mock.mock({
        'list0|5': [{
            'name': '@ctitle(26)',
            'sellprice|160-200': 110,
            'payprice|100-150': 100,
            'username': '王馨',
            'count|1-15': 1,
            'color': '黑色',
            'size': 'M',
            'createtime': '2017-10-12 15:56:25',
            'order_number': '56564646464',
            'img': '@image(80x80)'
        }],
        'list1|5': [{
            'name': '@ctitle(26)',
            'createtime': '2017-10-12 15:56:25',
            'img': '@image(80x80)'
        }],
        'list2|5': [{
            'name': '@ctitle(26)',
            'createtime': '2017-10-12 15:56:25',
            'img': '@image(80x80)'
        }]
    })
    new Vue({
        el: '#pingjia_list',
        data() {
            return {
                topnavlist: {},
                pingjia_list: ['待评价', '待追评', '已评价'],
                nowIndex: 0,
                type:6,
                pageNo:1,
                pinJianList:[],
                titalCount:0,
                list1:[],
                list2:[],
                keyWord:null,
            }
        },
        methods: {
            getData(){
                let that=this;
                this.getDataList();
                this.list0 = mockData.list0; //待评价
                //that.list1 = mockData.list1; //待追评
                that.list2 = mockData.list2; //已评价
            },

            getDataList(){
                let that=this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/order/queryDataPC',
                    params: {
                       // productId: this.urlStream.productId,
                        orderStatus: this.type,
                        current:this.pageNo,
                        keyword:this.keyWord,
                        token: urlParam.token()
                    },
                    //  responseType: 'stream',
                }).then(function(response) {
                    if (response.data.code == 401) {
                        userLogin.ifLogin();
                    } else {
                        that.pinJianList=response.data.data.rows;
                        that.titalCount=response.data.data.total;
                    }
                });
            },
            daizhuijia(isall){
                let that=this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/comment/addCommentList',
                    params: {
                        // productId: this.urlStream.productId,
                        allOrAdd:isall,
                        pageNo:this.pageNo-1,
                        keyWord:this.keyWord,
                        token: urlParam.token()
                    },
                    //  responseType: 'stream',
                }).then(function(response) {
                    if (response.data.code == 401) {
                        userLogin.ifLogin();
                    } else {
                        console.log(response.data.data.productComments);
                        if(isall==0){
                            that.list1=response.data.data.productComments;
                        }else{
                            that.list2=response.data.data.productComments;
                        }
                    }
                });
            },

            seach(){
                if(this.keyWord!=""){
                    this.pageNo=1;
                    if(this.index==0){
                        this.getDataList();
                    }else if(index==1){
                        this.daizhuijia(0);
                    }else {
                        this.daizhuijia(1);
                    }
                }

            },

            toggleTabs: function (index) {
                this.nowIndex = index;
                this.pageNo=1;
                if(index==0){
                    this.getDataList();
                }else if(index==1){
                    this.daizhuijia(0);
                }else {
                    this.daizhuijia(1);
                }
            },
            listen: function (index) {
                // 翻页事件
                this.pageNo=index;
                //this.where.pages=index-1;
                this.getList();
            }
        },
        created(){
            this.getData();
        }
    })
}